@model IEnumerable<Product>
@{
    ViewBag.Title = "All Products";
    Layout = "_AdminLayout";
}
@if(Model.Count()==0){
  <div class="text-center m-2">
    <form asp-action="SeedDatabase" method="post">
      <button type="submit" class="btn btn-danger">Seed Database</button>
    </form>
  </div>
}else{
  <table class="table table-striped table-bordered table-sm">
    <tr>
      <th class="text-right">ID</th>
      <th>Name</th>
      <th class="text-right">Price</th>
      <th class="text-center">Actions</th>
    </tr>
        @foreach(var item in Model)
        {
            <tr>
              <td class="text-right">@item.ProductID</td>
              <td>@item.Name</td>
              <td class="text-right">@item.Price.ToString("c")</td>
              <td class="text-center">
                <form asp-action="Delete" method="post">
                  <a asp-action="Edit" class="btn btn-sm btn-warning" asp-route-productId="@item.ProductID">
                    Edit
                  </a>
                  <input type="hidden" name="ProductID" value="@item.ProductID"/>
                  <button type="submit" class="btn btn-danger btn-sm">
                    Delete
                  </button>
                </form>
              </td>
            </tr>
        }
    </table>
}
<div class="text-center">
  <a asp-action="Create" class="btn btn-primary">Add Product</a>
</div>
